/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/20
 * Time: 9:17
 * Description:
 */
class Student {
    private String name;
    private int age;

    {
        this.age = 999;
        System.out.println("实例代码块！");
    }

    static {
        //this.name = "hello"; error
        count = 111111;
        System.out.println("静态代码块！");
    }

    public static int count=99;

    public Student() {
        //this("bit");
        //this("bit",10);//this();
        System.out.println("不带有参数的构造方法！");
    }

    //构造方法:没有返回值，方法名称和类名是一样的
    public Student(String name) {
        //this("bit",10);
        this.name = name;
        System.out.println("带有一个String参数的构造方法！");
    }



    public Student(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("带有2个参数的构造方法！");
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void sleep() {


        System.out.println(this.name+"睡觉！");
        System.out.println(this.getName()+"睡觉！");
    }

    public static void func() {
        //System.out.println(this.name+"func()!");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }


}

public class TestDemo2 {


    public static void func2(Student student) {

    }


    public static void main(String[] args) {
        func2(new Student());



        System.out.println(new Student().getName());

        System.out.println(new Student().getAge());

        System.out.println("=====================");
        Student student = new Student();

        System.out.println(student.getName()+" "+student.getAge());
    }


    public static void main3(String[] args) {
        Student student = new Student();
        System.out.println(student);
        //System.out.println(student.getAge());

        /*System.out.println(Student.count);*/
        //Student.func();

    }

    public static void main2(String[] args) {
        Student student = new Student();
        System.out.println("===============");
        Student student2 = new Student();

        // System.out.println(student);
    }




    public static void main1(String[] args) {
        Student student = new Student("bit");
        System.out.println(student);

        Student student2 = new Student("bit",10);
        System.out.println(student2);

    }
}
